package code.example.qrcode;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class QrCodeTester {

    public void createQrCode(String data,int width,int height,String format,String filePath) throws Exception {
        BufferedImage image = QrCodeKit.createQRCode(data, width,height);
        ImageIO.write(image, format, new File(filePath));
    }

    public void createQrCodeWithLogo(String data,int width,int height,String format,String filePath,String logoFilePath) throws Exception {
        BufferedImage image = QrCodeKit.createQRCodeWithLogo(data, width,height,new File(logoFilePath));
        ImageIO.write(image, format, new File(filePath));
    }
    public static void main(String []args ){
        try {
            QrCodeTester qrCodeTester=new QrCodeTester();
            qrCodeTester.createQrCode("{\"name\":\"ying\",\"id\":18383}",400,400,"png","qrcode/qrcode1.png");
            qrCodeTester.createQrCodeWithLogo("{\"name\":\"ying\",\"id\":18383}",400,400,"png","qrcode/qrcode2.png","qrcode/logo.jpg");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
